using System;

namespace Blader.UI.TextBox
{
    /// <summary>
    /// Summary description for TextLengthTrigger.
    /// </summary>
    [Serializable]
    public class TextLengthTrigger : AutoCompleteTrigger
    {
        private int textLength = 2;

        public TextLengthTrigger()
        {
        }

        public TextLengthTrigger(int length)
        {
            textLength = length;
        }

        public int TextLength
        {
            get { return textLength; }
            set { textLength = value; }
        }

        public override TriggerState OnTextChanged(string text)
        {
            if (text.Length >= TextLength)
                return TriggerState.Show;
            return text.Length < TextLength ? TriggerState.Hide : TriggerState.None;
        }
    }
}